Repository navigation
fix(contexts): delete the applications of a deleted user - #3196
Open
rubenvdlinde wants to merge 1 commit into
Open
rubenvdlinde wants to merge 1 commit into
rubenvdlinde wants to merge 1 commit into
Conversation
Deleting a user removed their tables but left their applications behind, with pages, shares and navigation entries, owned by nobody. The user deleted listener now deletes the applications the user owns through ContextService::delete(), before their tables. Applications only shared with the user, or owned by a group, stay. ShareMapper::findAllSharesForNode() accepts a null sender: it is not used in the query, but deleting an application without a session user, as occ user:delete does, passed null and the TypeError aborted the user deletion. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
rubenvdlinde
force-pushed
the
fix/noid/delete-applications-of-deleted-user
branch
from
November 3, 2026 14:51
7ec3770 to
11c8005
Compare
rubenvdlinde
marked this pull request as ready for review
November 6, 2026 08:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a user was deleted, Tables removed their tables but not their applications. The application stayed in the database with its pages, its shares and the navigation entries of the people it was shared with, owned by a user who no longer exists.
Size: 195 lines: 38 code and 157 tests.
What changes
UserDeletedListenernow deletes the applications the user owns before it deletes their tables. Applications the user only received through a share are left alone, and so are applications owned by a group. Each application goes throughContextService::delete(), the same path as deleting it in the UI, so its node relations, pages, page content, shares and navigation entries go with it. Applications go first, so deleting the tables doesn't have to detach them from applications that are removed anyway.ShareMapper::findAllSharesForNode()accepts a null sender. The parameter isn't used in the query, butShareService::deleteAllForContext()passes the session user, which is null when there's no session:occ user:delete, or a user backend removing users in the background. Without this, deleting an application there threw aTypeErrorthat aborted the whole user deletion.Because the listener goes through
ContextService::delete(), anything that method learns to clean up later is also cleaned up when a user is deleted. The widgets and menu items from #3132 and #3135 are both removed in that method, so they need no change here.How it was tested
tests/unit/Listener/UserDeletedListenerTest.php: only applications the user owns are deleted, applications are deleted before tables, a failing application doesn't stop the rest, and other events are ignored.ShareServiceTest:deleteAllForContext()works without a session user. Without the fix it fails with theTypeErrorabove.On a local instance, a user with one table and one application on it. The application is shared with another user, who has it in their navigation. Then the user is deleted. Rows left for that application afterwards, on main and with this change:
DELETE /cloud/users/{id}occ user:deleteWith only the listener change,
occ user:deletefailed with theTypeErrorand the user wasn't deleted at all. That is what theShareMapperchange fixes.🖼️ Screenshots
Backend only, no visual change.
🏁 Checklist
/backport to stableX.X🤖 AI (if applicable)